600_03_Quarto

Quarto sample book with HTML
Author

Tomaz Kastrun

Published

March 27, 2025

Abstract
Simple QMD for educational purposes

1 Report on analysis of Iris datasets

1.1 Tabsets

fizz_buzz <- function(fbnums = 1:50) {
  output <- dplyr::case_when(
    fbnums %% 15 == 0 ~ "FizzBuzz",
    fbnums %% 3 == 0 ~ "Fizz",
    fbnums %% 5 == 0 ~ "Buzz",
    TRUE ~ as.character(fbnums)
  )
  print(output)
}
val1 = 6  
val2 = 7
val3 = "s"  
result = switch(  
    val3,  
    "a"= cat("Addition =", val1 + val2),  
    "d"= cat("Subtraction =", val1 - val2),  
    "r"= cat("Division = ", val1 / val2),  
    "s"= cat("Multiplication =", val1 * val2),
    "m"= cat("Modulus =", val1 %% val2),
    "p"= cat("Power =", val1 ^ val2)
)  
print(result)

1.2 Exploring data

Based on the group selected setosa, here is the table data.

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa

And calculating for Species setosa and number of observations 50.

1.3 1. Checking custom fits

This is a custom function fit:


Call:
lm(formula = Petal.Length ~ Petal.Width, data = d)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.43686 -0.09151 -0.03686  0.09018  0.46314 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.32756    0.05996  22.141   <2e-16 ***
Petal.Width  0.54649    0.22439   2.435   0.0186 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.1655 on 48 degrees of freedom
Multiple R-squared:   0.11, Adjusted R-squared:  0.09144 
F-statistic: 5.931 on 1 and 48 DF,  p-value: 0.01864

1.4 Running multiple regression

You can add options to run multiple regression

Code
library(tidyverse)

d <- iris %>% select(Petal.Length, Petal.Width, Sepal.Length, Sepal.Length)


fit <- lm(Petal.Width ~ Sepal.Length + Sepal.Length + Petal.Length, data = d)

# Obtain predicted and residual values
d$predicted <- predict(fit)
d$residuals <- residuals(fit)


ggplot(d, aes(x = Sepal.Length, y = Petal.Width)) +
  geom_segment(aes(xend = Sepal.Length, yend = predicted), alpha = .2) +  # Lines to connect points
  geom_point() +  # Points of actual values
  geom_point(aes(y = predicted), shape = 1) +  # Points of predicted values
  theme_bw()
Figure 1

1.5 Adding multiple predictors on graph:

Figure 2: Iris scatterplot with multiple predictors

1.6 Running multiple different code

1.6.1 Example with R

Here with using R Language.

Iris scatter between Petal.Width and Petal.Length

1.6.2 Example with Python

Example with Python

Code
a = 1

And overall it is irrelevant the origin of language. and mixing the languages

1.6.3 Math

some formula f(x) = a*b^{3} + 4

Some formula \sqrt{2x + 4^{3}}

Quadratic formula (or Sridharacharya formula) for second-order polynomial equation x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Bayes rules: Pr(\theta | y) = \frac{Pr(y | \theta) Pr(\theta)}{Pr(y)}

1.7 Adding additional table with gt() asis does not work. use it with html

Code
# install.packages("gt")
library(gt)

table_1 <- mtcars %>%
  head(5) %>% 
  gt()


print(table_1)
mpg cyl disp hp drat wt qsec vs am gear carb
21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
18.7 8 360 175 3.15 3.440 17.02 0 0 3 2

2 Conclusion

The results show bigger residuals and predicting the multiple variate regression without filtering the species, to be “interesting” idea.

Pay Attention

This analysis is fictitious and does not provide any real results